package com.hbter630.change.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Title: MyMetaObjectHandler
 * @Author 笑霸fianl
 * @Package com.hbter630.change.config
 * @Date 2023/5/23 9:01
 * @描述: 数据自动填充
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //属性名称，不是字段名称
        this.setFieldValByName("registrationDate", new Date(), metaObject);
        this.setFieldValByName("orderDate", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("registrationDate", new Date(), metaObject);
        this.setFieldValByName("orderDate", new Date(), metaObject);
    }
}

